<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>message</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link href="../../css/app.css" rel="stylesheet" />
		<script src="../../js/mui.min.js"></script>
		<style>
			.special-row{
				
			}
			.special-row select{
				height:40px;
				padding: 10px 15px;
				margin-bottom: 0;
				display: inline-block;
				padding-left: 0;
				padding-right:0;
				width:10% !important;
				float: left !important;
				max-width: 2em;
			}
			
			.mui-input-row select {
			    line-height: 30px;
				height:60px;
				font-size:1em;
				max-width: 2em;
			}
			
			.special-row .special-input{
				width:54% !important;
				float:left !important;
			}
			.mui-input-group .mui-input-row {
			    height: 60px;
			}
			.mui-input-row label{
				font-size:20px;
			}
			.mui-input-row .mui-input-clear~.mui-icon-clear{
				    font-size: 30px;
				    top: 14px;
			}
			
			input[type=text],input[type=select]{
				line-height: 30px;
				height:60px;
				font-size:20px;
			}
			.mui-input-row label {
			    font-family: 'Helvetica Neue',Helvetica,sans-serif;
			    line-height: 2;
			    float: left;
			    width: 35%;
			    padding: 11px 15px;
			}
		</style>
		
	</head>  

	<body>
		<header class="mui-bar mui-bar-nav app-main-background-color" >
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">案件添加</h1>
		</header>
		<div class="mui-content">
		    <div  class="mui-input-group">
				<div class="mui-input-row">
					<label>案件号</label>
					<input id="CASE_CODE" type="text" class="mui-input-clear mui-input" placeholder="请输入案件号">
				</div>
				<div class="mui-input-row special-row">
					<label>车牌号</label>
					
					<select id="AREA">
						
					</select>
					<input  id="AUTO_NO" type="text" style="" class="special-input" placeholder="车牌号">
				</div>
			</div>
			<div class="mui-content-padded">
				<button class="mui-btn mui-btn-block mui-btn-primary" id="next">下一步</button>
			</div>
		</div>
		<script src="../../js/jquery-1.12.4.min.js"></script>
		<script src="../../js/app.js"></script>
		
		<script type="text/javascript">
				mui.init();	
				function initAreaList(){
					var selectEL=$("#AREA");
					for(var i=0;i<=app.arealist.length-1; i++){
						selectEL.append('<option value="'+ app.arealist[i].value+'">' + app.arealist[i].name+ '</option>');
					}
				}
				initAreaList();
				mui.plusReady(function(){ 
					
				});
				
				
				mui('.mui-content-padded').on('tap','#next',function(e) {
					
						var caseInfo = {};
						caseInfo.CASE_CODE = document.getElementById("CASE_CODE").value;
						caseInfo.AREA = document.getElementById("AREA").value;
						
						caseInfo.AUTO_NO   = document.getElementById("AUTO_NO").value;
						if (caseInfo.CASE_CODE == "") {
								plus.nativeUI.toast('案件号不能为空');
								return false;
						}
						if (caseInfo.AUTO_NO == "") {
								plus.nativeUI.toast('车牌号不能为空');
								return false;
						}
						if(caseInfo.AREA != ""){
							
							var autoNoExpress = /^[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
							if(!autoNoExpress.test(caseInfo.AUTO_NO)){
								plus.nativeUI.toast('车牌号格式有误,请重新输入!');
								return false;
							}
							caseInfo.AUTO_NO = caseInfo.AREA + caseInfo.AUTO_NO ;
						}
						
						
					
						app.addCase(caseInfo,function(resp){
							console.log(resp.result_code);
							
							var result_code = resp.result_code;
							var result_msg  = resp.result_msg;
							if(result_code === 0){
								var result_data = resp.result_data;
								var caseUid  = result_data.UID; 
								var caseCode = result_data.CASE_CODE; 
									mui.openWindow({
										url:"/html/case/upimage.html",
										id:"/html/case/upimage.html",
										show: {
											aniShow: 'pop-in'
										},
										waiting: {
											autoShow: false
										},
										createNew:true,
										 extras:{
											"CASE_UID":caseUid,
											"CASE_CODE":caseCode
			    					},
								});
							}
							else if(result_code === -3){
								mui.toast('案件号已存在！');
							}
							else if(result_code == -99){
								mui.toast('登录过期，请重新登录');
								app.toLogin();
							}
							
						});						
						
				});
		</script>
	</body>


</html>    